/**
 * 
 */
package com.tenement.utils;

import com.alibaba.druid.filter.config.ConfigTools;
import com.github.pagehelper.util.StringUtil;
import com.tenement.domain.*;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ObjectUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 * 工具类
 * @author liandyao
 * @date 2017年9月29日 上午11:30:10
 * @version 1.0 
 * 
 * @author 原作者
 * @update 修改人 
 * @date 修改时间
 * 修改内容.................
 */
public class Tools {
	/**
	 * 分页每页显示条数
	 */
	public final static int PAGES_MAX_RESULT=5; 
	
	/**
	 * 是否有效 有效
	 */
	public final static String ISVA_YES = "有效" ;
	
	/**
	 * 是否有效 无效
	 */
	public final static String ISVA_NO = "无效";
	
	/**
	 * 日期格式
	 * yyyy-MM-dd
	 */
	public static SimpleDateFormat SDF_DATE = new SimpleDateFormat("yyyy-MM-dd");
	
	/**
	 * 时间格式
	 * yyyy-MM-dd HH:mm:ss
	 */
	public static SimpleDateFormat SDF_TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	/**
	 * 时间格式
	 * yyyy-MM-dd HH:mm:ss
	 */
	public static SimpleDateFormat SDF_TIME_NO = new SimpleDateFormat("yyyyMMddHHmmss");
	
	static Random random = new Random();

	static char[] char_random = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9', '0' };

	/**
	 * 随机生成字符串 共40位
	 * @return 随机字符串
	 */
	public static String getRandomString(){
		String s = RandomStringUtils.random(20,char_random) ;
		String s1 = RandomStringUtils.random(20, char_random) ;
		return s+s1 ;
	}

	/**
	 * 随机生成字符串
	 * @param size 位
	 * @return 随机字符串
	 */
	public static String getRandomString(int size){
		String s = RandomStringUtils.random(size,char_random) ; 
		return s  ;
	}
	/**
	 * 得到
	 * @return
	 */
	public static String getRandomUUID(){
		String s =  UUID.randomUUID().toString().replaceAll("-", "");
		return s  ;
	}
	/**
	 * 得到随机数字
	 * @param num
	 * @return
	 */
	public static int getRandomNumber(int num){
		int n = random.nextInt(num) ;
		return n ;
	}
	/**
	 * 提供字符串判断是否为空
	 * @param input
	 * @return input为空返回true
	 */
	public static boolean isEmpty(String input){
		return null==input || 0==input.length() || 0==input.replaceAll("\\s", "").length();
	}
	
	/**
	 * 判断集合是否为空
	 * @param list
	 * @return list为空返回true
	 */
	public static boolean isEmpty(List list){
		if(list==null) return true ;
		return list.isEmpty();
	}
	 
	/**
	 * 得到当前日期
	 * yyyy-MM-dd
	 * @return 格式化的r日期字符串
	 */
	public static String getCurDate(){
		Date date = new Date();
		return SDF_DATE.format(date);
	}
	
	/**
	 * 得到当前日期时间
	 * yyyy-MM-dd HH:mm:ss
	 * @return 格式化的r日期字符串
	 */
	public static String getCurDateTime(){
		Date date = new Date();
		return SDF_TIME.format(date);
	}
	
	/**
	 * 返回日期格式
	 * yyyy-MM-dd
	 * @param date
	 * @return 格式化的r日期字符串
	 */
	public static String getDateStr(Date date){
		if(date==null) return "";
		return SDF_DATE.format(date);
	}
	
	/**
	 * 返回时间格式
	 * yyyy-MM-dd HH:mm:ss
	 * @param date
	 * @return 格式化的r日期字符串
	 */
	public static String getTimeStr(Date date){
		if(date==null) return "";
		return SDF_TIME.format(date);
	}
	
	/**
	 * 得到订单编码格式:日期格式如:20161222211800,分别代表的是年月日时分秒+5位随机字符串
	 * @return
	 */
	public static String getDateOrderNo(){
		Date date = new Date();
		String temp = SDF_TIME_NO.format(date);
		temp = temp+getRandomString(10);
		return temp ;
	}
	/**
	 * 得到订单编码格式:日期格式如:20161222211800,分别代表的是年月日时分秒+5位随机字符串
	 * @return
	 */
	public static String getDateOrderNumber(){
		Date date = new Date();
		String temp = SDF_TIME_NO.format(date);
		temp = temp+getRandomNumber(5);
		return temp ;
	}

	/**
	 * 得到多少月份之后的时间
	 * @param size 多少月
	 * @return 返回字符串
	 */
	public static String getAfterDate(int size){
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.MONTH, size);

		Date date = cal.getTime();
		String str = SDF_DATE.format(date);
		return str ;
	}

	/**
	 * 与当前时间比
	 * @param date
	 * @return 如果未超过返回true，如果已经超过返回false
	 * @throws ParseException 
	 */
	public static boolean isDateBefore(String date) throws ParseException{
		if(isEmpty(date)) return false ;
		Date exp = SDF_TIME.parse(date);
		Date now = new Date();
		return now.before(exp);
	}
	
	/**
     * 获取前一天日期yyyyMMdd
     * @return 返回的日期格式为yyyyMMdd
     */
    public static String getYestoday(){
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, -1);
        return SDF_DATE.format(calendar.getTime());
    }
	
	/**
	 * 将首字母大写
	 * @param name 属性名
	 * @return 例如传入属性name,得到的结果是Name
	 */
	public static String firstUpp(String name){
		if(isEmpty(name)) return name ;
		char first = name.charAt(0) ;
		String newName = Character.toUpperCase(first)+name.substring(1) ;
		return newName ;
	}
	
	/**
	 * 将字符串编码,utf-8格式
	 * @param str
	 * @return
	 */
	public static String encode(String str){
		try {
			 return URLEncoder.encode(str, "utf-8");
		} catch (UnsupportedEncodingException e) { 
			e.printStackTrace();
		}
		return null ;
	}
	
	 /**
     * 字符解码
     * @param  chinese 该方法默认会以UTF-8解码字符串
     *  若想自己指定字符集,可以使用<code>decode(String chinese, String charset)</code>方法
     */
    public static String decode(String chinese){
        return decode(chinese, "UTF-8");
    }
    
    /**
     * 字符解码
     *  该方法通常用于对中文进行解码
     *   若系统不支持指定的解码字符集,则直接将<code>chinese</code>原样返回
     */
    public static String decode(String chinese, String charset){
        chinese = (chinese==null ? "" : chinese);
        try {
            return URLDecoder.decode(chinese, charset);
        } catch (UnsupportedEncodingException e) {

            return chinese;
        }
    }
	
	/**
	 * 得到当前时间戳,1970年到目前的秒数
	 * @return 时间戳
	 */
	public static String getTimeStamp(){
		return System.currentTimeMillis()/1000+"";
	}
	
	 /**
     * 获取系统流水号
     *  若欲指定返回值的长度or是否全由数字组成等,you can call
     * @return 长度为20的全数字
     */
    public static String getSysJournalNo(){
        return getSysJournalNo(20, true);
    }
	
	/**
     * 获取系统流水号
     * @param length   指定流水号长度
     * @param isNumber 指定流水号是否全由数字组成
     */
    public static String getSysJournalNo(int length, boolean isNumber){
        //replaceAll()之后返回的是一个由十六进制形式组成的且长度为32的字符串
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        if(uuid.length() > length){
            uuid = uuid.substring(0, length);
        }else if(uuid.length() < length){
            for(int i=0; i<length-uuid.length(); i++){
                uuid = uuid + Math.round(Math.random()*9);
            }
        }
        if(isNumber){
            return uuid.replaceAll("a", "1").replaceAll("b", "2").replaceAll("c", "3").replaceAll("d", "4").replaceAll("e", "5").replaceAll("f", "6");
        }else{
            return uuid;
        }
    }
    
    /**
     * 金额元转分
     *  注意:该方法可处理贰仟万以内的金额,且若有小数位,则不限小数位的长度
     *   注意:如果你的金额达到了贰仟万以上,则不推荐使用该方法,否则计算出来的结果会令人大吃一惊
     * @param amount  金额的元进制字符串
     * @return String 金额的分进制字符串
     */
    public static String moneyYuanToFen(String amount){
        if(isEmpty(amount)){
            return amount;
        }
        //传入的金额字符串代表的是一个整数
        if(-1 == amount.indexOf(".")){
            return Integer.parseInt(amount) * 100 + "";
        }
        //传入的金额字符串里面含小数点-->取小数点前面的字符串,并将之转换成单位为分的整数表示
        int money_fen = Integer.parseInt(amount.substring(0, amount.indexOf("."))) * 100;
        //取到小数点后面的字符串
        String pointBehind = (amount.substring(amount.indexOf(".") + 1));
        //amount=12.3
        if(pointBehind.length() == 1){
            return money_fen + Integer.parseInt(pointBehind)*10 + "";
        }
        //小数点后面的第一位字符串的整数表示
        int pointString_1 = Integer.parseInt(pointBehind.substring(0, 1));
        //小数点后面的第二位字符串的整数表示
        int pointString_2 = Integer.parseInt(pointBehind.substring(1, 2));
        //amount==12.03,amount=12.00,amount=12.30
        if(pointString_1 == 0){
            return money_fen + pointString_2 + "";
        }else{
            return money_fen + pointString_1*10 + pointString_2 + "";
        }
    }
    
    /**
     * 金额分转元
     *   注意:如果传入的参数中含小数点,则直接原样返回
     *   该方法返回的金额字符串格式为<code>00.00</code>,其整数位有且至少有一个,小数位有且长度固定为2
     * @param amount  金额的分进制字符串
     * @return String 金额的元进制字符串
     */
    public static String moneyFenToYuan(String amount){
        if(isEmpty(amount)){
            return amount;
        }
        if(amount.indexOf(".") > -1){
            return amount;
        }
        if(amount.length() == 1){
            return "0.0" + amount;
        }else if(amount.length() == 2){
            return "0." + amount;
        }else{
            return amount.substring(0, amount.length()-2) + "." + amount.substring(amount.length()-2);
        }
    }
    
    /**
     * 获取一个字符串的简明效果,可以作为手机号码或者身份证号码的隐藏,例如1345***4568
     * @return String 返回的字符串格式类似于"abcd***hijk"
     */
    public static String getStringSimple(String data){
        return data.substring(0,4) + "***" + data.substring(data.length()-4);
    }
    
    /**
     * 将字符串加密,一般用于密码加密
     * @param str 传入普通字符串
     * @return 返回加密之后的字符串
     */
    public static String password(String str){
    	if(str==null) return null;
    	String password = null;
		try {
			password = ConfigTools.encrypt(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	return password ;
    }

	/**
	 * 回调函数
	 * @param row
	 * @return
	 */
	public static Message rows(int row){
		Message message=new Message();
		if(row>0){
			message.setNum(1);
			message.setMsg("操作成功");
		}else{
			message.setNum(0);
			message.setMsg("操作失败");
		}
		return message;
	}


	/**
	 * layui前台响应模型
	 * @param overCount 总行数
	 * @param list 数据集合
	 * @return
	 */
	public static Map maps(Long overCount,List list){
		Map<String,Object> map=new HashMap<>();
		map.put("code",0); // 放入 code ，0
		map.put("msg", ""); // 放入msg “”
		map.put("count",overCount); // 放入总行数
		map.put("data", list);
		return map;
	}

	/**
	 * 获取当前时间
	 * @return
	 * @throws ParseException
	 */
	public static Date date(String dates) throws ParseException {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		return sdf.parse(dates);
	}

	public static void logclientMods(List<TenementClient> clients,StringBuffer logBody){
		for (TenementClient client : clients) {
			logclientMod(client,logBody);
		}
	}

	/**
	 * 客户日志模型
	 * @param client
	 * @param logBody
	 */
	public static void logclientMod(TenementClient client,StringBuffer logBody){
		if(client!=null){
			if(!StringUtil.isEmpty(client.getClientName())){
				logBody.append("客户名称：");
				logBody.append(client.getClientName());
			}

			if(!StringUtil.isEmpty(client.getClientIdentity())){
				logBody.append("；编号：");
				logBody.append(client.getClientIdentity());
			}

			if(!StringUtil.isEmpty(client.getClientId())){
				logBody.append("；客户id：");
				logBody.append(client.getClientId());
			}

			if(client.getClientSex() != null){
				logBody.append("；客户性别：");
				if(client.getClientSex()==1){
					logBody.append("男");
				}else{
					logBody.append("女");
				}
			}

			if(!StringUtil.isEmpty(client.getClientPhone())){
				logBody.append("；客户电话：");
				logBody.append(client.getClientPhone());
			}

			if(!ObjectUtils.isEmpty(client.getClientMoney())){
				logBody.append("；最低接受金额：");
				logBody.append(client.getClientMoney());
			}

			if(!ObjectUtils.isEmpty(client.getClientPayment())){
				logBody.append("；最高接受金额：");
				logBody.append(client.getClientPayment());
			}

			if(!ObjectUtils.isEmpty(client.getClientState())){
				logBody.append("；最低需求面积：");
				logBody.append(client.getClientState());
			}

			if(!ObjectUtils.isEmpty(client.getClientStates())){
				logBody.append("；最高需求面积：");
				logBody.append(client.getClientStates());
			}

			if(!StringUtil.isEmpty(client.getClientIndustry())){
				logBody.append("；业态：");
				logBody.append(client.getClientIndustry());
			}

			if(!StringUtil.isEmpty(client.getClientSource())){
				logBody.append("；来源：");
				logBody.append(client.getClientSource());
			}

			if(!StringUtil.isEmpty(client.getRemark())){
				logBody.append("；备注：");
				logBody.append(client.getRemark());
			}

			if(!StringUtil.isEmpty(client.getClientIdentity())){
				logBody.append("；编号：");
				logBody.append(client.getClientIdentity());
			}

			if(!StringUtil.isEmpty(client.getClientFollow())){
				logBody.append("；跟进总内容：");
				logBody.append(client.getClientFollow());
			}

			if(!StringUtil.isEmpty(client.getCreatedBy())){
				logBody.append("；创建人：");
				logBody.append(client.getCreatedBy());
			}

			if(!ObjectUtils.isEmpty(client.getCreatedTime())){
				logBody.append("；创建时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(client.getCreatedTime()));
			}

			if(!StringUtil.isEmpty(client.getUpdatedBy())){
				logBody.append("；更新人：");
				logBody.append(client.getUpdatedBy());
			}

			if(!ObjectUtils.isEmpty(client.getUpdatedTime())){
				logBody.append("；更新时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(client.getUpdatedTime()));
			}



		}
	}

	/**
	 * 带看日志模型
	 * @param guideVo
	 * @param logBody
	 */
	public static void logGuideMod(GuideVo guideVo,StringBuffer logBody){
		if(guideVo!=null){
			if(!StringUtil.isEmpty(guideVo.getGuideName())){
				logBody.append("带看描述：");
				logBody.append(guideVo.getGuideName());
			}

			if(!StringUtil.isEmpty(guideVo.getGuideId())){
				logBody.append("；带看id：");
				logBody.append(guideVo.getGuideId());
			}

			if(!StringUtil.isEmpty(guideVo.getUserId())){
				logBody.append("；带看用户id：");
				logBody.append(guideVo.getUserId());
			}

			if(!StringUtil.isEmpty(guideVo.getUserName())){
				logBody.append("；带看用户名称：");
				logBody.append(guideVo.getUserName());
			}

			if(!ObjectUtils.isEmpty(guideVo.getHouseId())){
				logBody.append("；带看房源id：");
				logBody.append(guideVo.getHouseId());
			}

			if(!ObjectUtils.isEmpty(guideVo.getHouseName())){
				logBody.append("；带看房源名称：");
				logBody.append(guideVo.getHouseName());
			}

			if(!ObjectUtils.isEmpty(guideVo.getGuideData())){
				logBody.append("；带看时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(guideVo.getGuideData()));
			}

			if(!StringUtil.isEmpty(guideVo.getClientId())){
				logBody.append("；客户id：");
				logBody.append(guideVo.getClientId());
			}

			if(!ObjectUtils.isEmpty(guideVo.getGuideImgs())){
				logBody.append("；带看图片地址集：");
				for (TenementGuideImg guideImg : guideVo.getGuideImgs()) {
					logBody.append(guideImg.getImgUrl());
					logBody.append(",");
				}
			}

		}
	}

	public static void logHouseMods(List<TenementHouse> houses,StringBuffer logBody){
		for (TenementHouse house : houses) {
			logHouseMod(house,logBody);
		}
	}

	/**
	 * 房源日志模型
	 * @param house
	 * @param logBody
	 */
	public static void logHouseMod(TenementHouse house, StringBuffer logBody){
		if(house!=null){
			if(!StringUtil.isEmpty(house.getUserId())){
				logBody.append("房源编号：");
				logBody.append(house.getUserId());
			}

			if(!StringUtil.isEmpty(house.getHouseId())){
				logBody.append("；房源id：");
				logBody.append(house.getHouseId());
			}

			if(!StringUtil.isEmpty(house.getUserName())){
				logBody.append("；房源地址：");
				logBody.append(house.getUserName());
			}

			if(!StringUtil.isEmpty(house.getSectorName())){
				logBody.append("；区域名称：");
				logBody.append(house.getSectorName());
			}

			if(!ObjectUtils.isEmpty(house.getHouseArea())){
				logBody.append("；房屋面积：");
				logBody.append(house.getHouseArea());
			}

			if(!ObjectUtils.isEmpty(house.getHousePrice())){
				logBody.append("；房屋价格：");
				logBody.append(house.getHousePrice());
			}

			if(!StringUtil.isEmpty(house.getHousePhone())){
				logBody.append("；联系方式：");
				logBody.append(house.getHousePhone());
			}

			if(!StringUtil.isEmpty(house.getCreatedPhone())){
				logBody.append("；创建人手机：");
				logBody.append(house.getCreatedPhone());
			}

			if(!StringUtil.isEmpty(house.getHouseParticular())){
				logBody.append("；详细信息：");
				logBody.append(house.getHouseParticular());
			}


			if(!StringUtil.isEmpty(house.getHouseFollow())){
				logBody.append("；跟进总内容：");
				logBody.append(house.getHouseFollow());
			}

			if(!StringUtil.isEmpty(house.getCreatedBy())){
				logBody.append("；创建人：");
				logBody.append(house.getCreatedBy());
			}

			if(!ObjectUtils.isEmpty(house.getCreatedTime())){
				logBody.append("；创建时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(house.getCreatedTime()));
			}

			if(!StringUtil.isEmpty(house.getUpdatedBy())){
				logBody.append("；更新人：");
				logBody.append(house.getUpdatedBy());
			}

			if(!ObjectUtils.isEmpty(house.getUpdatedTime())){
				logBody.append("；更新时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(house.getUpdatedTime()));
			}

		}
	}

	public static void logHouseOrClientMods(List<TenementHouseClient> houseClients,StringBuffer logBody){
		for (TenementHouseClient houseClient : houseClients) {
			logHouseOrClientMod(houseClient,logBody);
		}
	}


	/**
	 * 通知日志模型
	 * @param houseClient 通知模型
	 * @param logBody 日志信息
	 */
	public static void logHouseOrClientMod(TenementHouseClient houseClient, StringBuffer logBody){
		if(houseClient!=null){
			if(!StringUtil.isEmpty(houseClient.getHouseClientId())){
				logBody.append("通知id：");
				logBody.append(houseClient.getHouseClientId());
			}

			if(!StringUtil.isEmpty(houseClient.getClientId())){
				logBody.append("；通知标题：");
				logBody.append(houseClient.getClientId());
			}

			if(!StringUtil.isEmpty(houseClient.getClientName())){
				logBody.append("；通知内容：");
				logBody.append(houseClient.getClientName());
			}

			if(!StringUtil.isEmpty(houseClient.getCreatedBy())){
				logBody.append("；创建人：");
				logBody.append(houseClient.getCreatedBy());
			}

			if(!ObjectUtils.isEmpty(houseClient.getCreatedTime())){
				logBody.append("；创建时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(houseClient.getCreatedTime()));
			}

			if(!StringUtil.isEmpty(houseClient.getUpdatedBy())){
				logBody.append("；更新人：");
				logBody.append(houseClient.getUpdatedBy());
			}

			if(!ObjectUtils.isEmpty(houseClient.getUpdatedTime())){
				logBody.append("；更新时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(houseClient.getUpdatedTime()));
			}

		}
	}

	/**
	 * 基金
	 * @param performances
	 * @param logBody
	 */
	public static void logPerformanceMods(List<TenementPerformance> performances,StringBuffer logBody){
		for (TenementPerformance performance : performances) {
			logPerformanceMod(performance,logBody);
		}
	}

	/**
	 * 基金
	 * @param performance
	 * @param logBody
	 */
	public static void logPerformanceMod(TenementPerformance performance, StringBuffer logBody){
		if(performance!=null){
			if(!StringUtil.isEmpty(performance.getPerformanceId())){
				logBody.append("业绩id：");
				logBody.append(performance.getPerformanceId());
			}

			if(!ObjectUtils.isEmpty(performance.getUserId())){
				logBody.append("；用户id：");
				logBody.append(performance.getUserId());
			}

			if(!StringUtil.isEmpty(performance.getUserName())){
				logBody.append("；用户名称：");
				logBody.append(performance.getUserName());
			}

			if(!ObjectUtils.isEmpty(performance.getHouseId())){
				logBody.append("；房源id：");
				logBody.append(performance.getHouseId());
			}

			if(!StringUtil.isEmpty(performance.getHouseName())){
				logBody.append("；房源名称：");
				logBody.append(performance.getHouseName());
			}

			if(!ObjectUtils.isEmpty(performance.getPerformanceMoney())){
				logBody.append("；成交价格：");
				logBody.append(performance.getHouseId());
			}

			if(!ObjectUtils.isEmpty(performance.getPerformanceBrokerage())){
				logBody.append("；佣金：");
				logBody.append(performance.getHouseId());
			}

			if(!StringUtil.isEmpty(performance.getClientPhone())){
				logBody.append("；客户电话：");
				logBody.append(performance.getHouseName());
			}

			if(!ObjectUtils.isEmpty(performance.getClientDivide())){
				logBody.append("；客户分成：");
				logBody.append(performance.getHouseId());
			}

			if(!ObjectUtils.isEmpty(performance.getUserDivide())){
				logBody.append("；用户分成：");
				logBody.append(performance.getHouseId());
			}

			if(!ObjectUtils.isEmpty(performance.getHouseDivide())){
				logBody.append("；房源分成：");
				logBody.append(performance.getHouseId());
			}

			if(!ObjectUtils.isEmpty(performance.getPerformanceBrokerage())){
				logBody.append("；基金分成：");
				logBody.append(performance.getHouseId());
			}

			if(!ObjectUtils.isEmpty(performance.getFundDivide())){
				logBody.append("；业绩分成：");
				logBody.append(performance.getHouseId());
			}

			if(!ObjectUtils.isEmpty(performance.getPerformanceDate())){
				logBody.append("；成交日期：");
				logBody.append(performance.getHouseId());
			}

			if(!StringUtil.isEmpty(performance.getPerformanceRemark())){
				logBody.append("；成交备注：");
				logBody.append(performance.getHouseId());
			}

			if(!StringUtil.isEmpty(performance.getCreatedBy())){
				logBody.append("；创建人：");
				logBody.append(performance.getCreatedBy());
			}

			if(!ObjectUtils.isEmpty(performance.getCreatedTime())){
				logBody.append("；创建时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(performance.getCreatedTime()));
			}

			if(!StringUtil.isEmpty(performance.getUpdatedBy())){
				logBody.append("；更新人：");
				logBody.append(performance.getUpdatedBy());
			}

			if(!ObjectUtils.isEmpty(performance.getUpdatedTime())){
				logBody.append("；更新时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(performance.getUpdatedTime()));
			}

		}
	}

	/**
	 * 跟进
	 * @param streets
	 * @param logBody
	 */
	public static void logStreetMods(List<TenementStreet> streets,StringBuffer logBody){
		for (TenementStreet street : streets) {
			logStreetMod(street,logBody);
		}
	}

	/**
	 * 跟进
	 * @param street
	 * @param logBody
	 */
	public static void logStreetMod(TenementStreet street, StringBuffer logBody){
		if(street!=null){
			if(!StringUtil.isEmpty(street.getStreetId())){
				logBody.append("跟进id：");
				logBody.append(street.getStreetId());
			}

			if(!StringUtil.isEmpty(street.getUserId())){
				logBody.append("；用户id：");
				logBody.append(street.getUserId());
			}

			if(!StringUtil.isEmpty(street.getUserName())){
				logBody.append("；用户名称：");
				logBody.append(street.getUserName());
			}

			if(!StringUtil.isEmpty(street.getSectorId())){
				logBody.append("；关联id：");
				logBody.append(street.getSectorId());
			}

			if(!StringUtil.isEmpty(street.getSectorName())){
				logBody.append("；内容：");
				logBody.append(street.getSectorName());
			}

			if(!ObjectUtils.isEmpty(street.getStreetName())){
				logBody.append("；跟进类型：");
				if(street.getStreetName()==0){
					logBody.append("客户");
				}else{
					logBody.append("房源");
				}
			}

			if(!StringUtil.isEmpty(street.getCreatedBy())){
				logBody.append("；创建人：");
				logBody.append(street.getCreatedBy());
			}

			if(!ObjectUtils.isEmpty(street.getCreatedTime())){
				logBody.append("；创建时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(street.getCreatedTime()));
			}

			if(!StringUtil.isEmpty(street.getUpdatedBy())){
				logBody.append("；更新人：");
				logBody.append(street.getUpdatedBy());
			}

			if(!ObjectUtils.isEmpty(street.getUpdatedTime())){
				logBody.append("；更新时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(street.getUpdatedTime()));
			}

		}
	}

	public static void logUserMods(List<TenementUser> users, StringBuffer logBody) {
		for (TenementUser tenementUser : users) {
			logUserMod(tenementUser,logBody);
		}
	}

	public static void logUserMod(TenementUser user, StringBuffer logBody){
		if(user!=null){
			if(!StringUtil.isEmpty(user.getUserId())){
				logBody.append("员工id：");
				logBody.append(user.getUserId());
			}

			if(!StringUtil.isEmpty(user.getUserName())){
				logBody.append("；员工名称：");
				logBody.append(user.getUserName());
			}

			if(!StringUtil.isEmpty(user.getUserAccount())){
				logBody.append("；员工账号：");
				logBody.append(user.getUserAccount());
			}

			if(!StringUtil.isEmpty(user.getUserPhone())){
				logBody.append("；手机：");
				logBody.append(user.getUserPhone());
			}

			if(!StringUtil.isEmpty(user.getUserIdentity())){
				logBody.append("；身份证：");
				logBody.append(user.getUserIdentity());
			}

			if(!ObjectUtils.isEmpty(user.getUserType())){
				logBody.append("；用户类型：");
				if(user.getUserType()==0){
					logBody.append("管理员");
				}else if(user.getUserType()==1){
					logBody.append("操作员");
				}else{
					logBody.append("员工");
				}
			}

			if(!StringUtil.isEmpty(user.getCreatedBy())){
				logBody.append("；创建人：");
				logBody.append(user.getCreatedBy());
			}

			if(!ObjectUtils.isEmpty(user.getCreatedTime())){
				logBody.append("；创建时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(user.getCreatedTime()));
			}

			if(!StringUtil.isEmpty(user.getUpdatedBy())){
				logBody.append("；更新人：");
				logBody.append(user.getUpdatedBy());
			}

			if(!ObjectUtils.isEmpty(user.getUpdatedTime())){
				logBody.append("；更新时间：");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				logBody.append(sdf.format(user.getUpdatedTime()));
			}

		}
	}

}
